How to get a List Element Value as a Integer?

Greetings folks,

I'm trying to use the code below to generate a list of all absolute numbers and then when the user selects it, to a automatically go to the object. Unfortunately the value i'm getting as an Integer is the position and i don't have a clue on how to get the values as integer.

Can anyone help me on how to do this?
 

DB test 
DBE lstTest
string arr [] = {}
 
/************ Populate List Element ************/
 
void populateList (DBE Elem)
{
    Module m = current
        Object o
        int i = 0
        string j
        for o in m do
        {
                j = o."Absolute Number"
                insert(lstTest, i, j)
                i++
                
        }
}
 
/************ List Action ************/
 
void sModGoTo (DBE Elem)
{
        int lstData
        int gtNum
        Module m = current
        string srcName = fullName(m)
        sMod = edit(srcName, true)
        sMod = current
        for(lstData=0;lstData<noElems(lstTest);lstData++)
        {
                if(selected(lstTest, lstData))
                {
                        gtNum = get(lstTest) /***I need this to be the value of the selection not the position***/
                        
                }
        }
        gotoObject(gtNum, sMod) /***I want the program to go to the object based on the selection***/
}
 
/************ GUI ************/
test = create("List Box", styleCentered)
lstTest = list(test, "Select Object ID", 5, arr)
 
realize(test)
 
populateList(lstTest)
set(lstTest, sModGoTo)
 
show(test)

SystemAdmin - Fri Sep 11 14:56:23 EDT 2009

Re: How to get a List Element Value as a Integer?
Ron_Lewis - Fri Sep 11 15:52:30 EDT 2009

Try:
 

DB test 
DBE lstTest
string arr [] = {}
 
/************ Populate List Element ************/
 
void populateList (DBE Elem)
{
    Module m = current
        Object o
        int i = 0
        string j
        for o in m do
        {
                j = o."Absolute Number"
                insert(lstTest, i, j)
                i++
                
        }
}
 
/************ List Action ************/
 
void sModGoTo (DBE Elem)
{       string s 
        int lstData
        int gtNum
        Module m = current
        string srcName = fullName(m)
        sMod = edit(srcName, true)
        sMod = current
        for(lstData=0;lstData<noElems(lstTest);lstData++)
        {
          if(selected(lstTest, lstData))
          s =get(lstTest) /***I need this to be the value of the selection not the position***/
         
        }
           gtNum = intOf s 
           gotoObject(gtNum, sMod) /***I want the program to go to the object based on the selection***/
}
 
/************ GUI ************/
test = create("List Box", styleCentered)
lstTest = list(test, "Select Object ID", 5, arr)
 
realize(test)
 
populateList(lstTest)
set(lstTest, sModGoTo)
show test

Re: How to get a List Element Value as a Integer?
SystemAdmin - Fri Sep 11 15:57:12 EDT 2009

Ron_Lewis - Fri Sep 11 15:52:30 EDT 2009

Try:
 

DB test 
DBE lstTest
string arr [] = {}
 
/************ Populate List Element ************/
 
void populateList (DBE Elem)
{
    Module m = current
        Object o
        int i = 0
        string j
        for o in m do
        {
                j = o."Absolute Number"
                insert(lstTest, i, j)
                i++
                
        }
}
 
/************ List Action ************/
 
void sModGoTo (DBE Elem)
{       string s 
        int lstData
        int gtNum
        Module m = current
        string srcName = fullName(m)
        sMod = edit(srcName, true)
        sMod = current
        for(lstData=0;lstData<noElems(lstTest);lstData++)
        {
          if(selected(lstTest, lstData))
          s =get(lstTest) /***I need this to be the value of the selection not the position***/
         
        }
           gtNum = intOf s 
           gotoObject(gtNum, sMod) /***I want the program to go to the object based on the selection***/
}
 
/************ GUI ************/
test = create("List Box", styleCentered)
lstTest = list(test, "Select Object ID", 5, arr)
 
realize(test)
 
populateList(lstTest)
set(lstTest, sModGoTo)
show test

Thank you very much. Gracias.

Re: How to get a List Element Value as a Integer?
llandale - Mon Sep 14 17:52:59 EDT 2009

Ron_Lewis - Fri Sep 11 15:52:30 EDT 2009

Try:
 

DB test 
DBE lstTest
string arr [] = {}
 
/************ Populate List Element ************/
 
void populateList (DBE Elem)
{
    Module m = current
        Object o
        int i = 0
        string j
        for o in m do
        {
                j = o."Absolute Number"
                insert(lstTest, i, j)
                i++
                
        }
}
 
/************ List Action ************/
 
void sModGoTo (DBE Elem)
{       string s 
        int lstData
        int gtNum
        Module m = current
        string srcName = fullName(m)
        sMod = edit(srcName, true)
        sMod = current
        for(lstData=0;lstData<noElems(lstTest);lstData++)
        {
          if(selected(lstTest, lstData))
          s =get(lstTest) /***I need this to be the value of the selection not the position***/
         
        }
           gtNum = intOf s 
           gotoObject(gtNum, sMod) /***I want the program to go to the object based on the selection***/
}
 
/************ GUI ************/
test = create("List Box", styleCentered)
lstTest = list(test, "Select Object ID", 5, arr)
 
realize(test)
 
populateList(lstTest)
set(lstTest, sModGoTo)
show test

Yes, you need to be a real stickler when reading the definitions in the manual, "int get(DBE)" being different than "string get(DBE)".

Doesn't the 'insert' require an input string? insert(1stTest, i, j "")

  • Louie

Re: How to get a List Element Value as a Integer?
SystemAdmin - Tue Sep 15 07:43:28 EDT 2009

llandale - Mon Sep 14 17:52:59 EDT 2009
Yes, you need to be a real stickler when reading the definitions in the manual, "int get(DBE)" being different than "string get(DBE)".

Doesn't the 'insert' require an input string? insert(1stTest, i, j "")

  • Louie

Yes, is supposed to be a string, the j is captured as a string in the for loop, I just leave it as a j because I was trying to use it as an int.